#!/usr/bin/env python
# encoding: utf-8
"""
@Author: Beam
@Mail:506556658@qq.com
@file: redis-常用操作.py
@time: 2017/6/2 10:25
"""


import redis
import time

pool = redis.ConnectionPool(host='192.168.6.248',port=63780,db=7,password='liang123456')  #连接池方式连接,用第6这个库
r = redis.Redis(connection_pool=pool)     #建立redis连接

# print(r.keys())
# print(r.keys('name?'))
# r.delete('info1')
# print(r.exists('info1'))  #exists不支持通配符，存在true，不存在false

# print(r.keys())
# r.expire('names',3)
# print(r.keys('names'))
# time.sleep(3)
# print(r.keys('names'))

# print(r.keys('newsource'))
# r.rename('newsource','nnsource')
# print(r.keys('newsource'))
# print(r.keys('nnsource'))

# print(r.type('zadd1'))

# r.move('nnsource',5)
# print(r.keys('nnsource'))


# print(r.randomkey())

# print(r.scan())

for i in r.scan_iter(): print(i)